package com.tencent.yumeko;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/producer")
public class RouterProducerController {
    private static Logger LOG = LoggerFactory.getLogger(RouterProducerController.class);

    @Value("${server.port:0}")
    private int port;

    /**
     * 获取生产者信息.
     *
     * @return information of producer
     */
    @PostMapping("/info")
    public String info(String name, @RequestBody User user) {
        LOG.info("Discovery Service Producer [{}] is called.", port);
        return String.format("Discovery Service Producer [%s] is called. user = %s", port, user);
    }
}
